This invention is directed to a system and method for facilitating platform independent fast communication. More particularly, the subject invention is directed to a shared memory based Inter-Process Communication (“IPC”) queue template to facilitate the fastest communication possible on any platform.
Shared memory allows one or more processes to communicate via memory that appears in all of their virtual address spaces. The pages of the virtual memory are referenced by page table entries in each of the sharing processes' page tables. It does not have to be at the same address in all of the processes' virtual memory. Access to shared memory areas is controlled via keys and access rights checking. Once the memory is being shared, there are no checks on how the processes are using it. They must rely on other mechanisms. When two processes attach the same shared memory segment, they are telling the operating system to relax the normal restrictions by mapping a portion of their address space onto the same memory. IPC message queues are transient memory areas, typically provided by the underlying operating system, used for communication between clients and servers.
A semaphore is a flag used to check whether a resource is currently being used by another thread or process. In its simplest form, a semaphore is a location in memory whose value can be tested and set by more than one process. The test and set operation is, so far as each process is concerned, uninterruptible or autonomous; once started nothing can stop it. The result of the test and set operation is the addition of the current value of the semaphore and the set value, which can be positive or negative. Depending on the result of the test and set operation one process may have to sleep until the semaphore's value is changed by another process. For example, if a process wants to use the printer, it first needs to make sure that the printer is available by checking to see if the semaphore has been set. If the semaphore is set, the process must wait until the process that currently has the printer is finished. However, if the printer were free, the process would set the semaphore and start using the printer, blocking access to all other processes until it finished.
Semaphores are a classical technique for protecting critical sections of code from being simultaneously executed by more than one thread. A semaphore is a generalization of a monitor. A monitor allows only one thread to lock an object at once. A semaphore allows N processes. The process of grabbing a semaphore for semi-exclusive use is called downing the semaphore because they are implemented with a countdown integer that decrements for each lock and increments for each unlock. If a semaphore is fully occupied, new threads wanting to use it will wait until some thread releases its lock by incrementing the semaphore. For a semaphore to work, the check for full and the decrement must be done all in one atomic uninterruptible instruction. The Java Virtual Machine (“JVM”) monitor instructions provide the needed hardware support to simulate semaphores.
Thus, there is a need for a system and method of providing fast communications between processes using inter-process communications queue templates in a shared memory manager.